import { defineStore } from 'pinia'
import { ref } from 'vue'
import permissRoute from '../permission'
export const useUserInfo = defineStore('user', () => {
  const userInfo = ref(JSON.parse(sessionStorage.getItem('userInfo') || '{}'))
  function setUserInfo (info) {
    userInfo.value = info
    sessionStorage.setItem('userInfo', JSON.stringify(info))
    permissRoute(info)
  }
  function clearUserInfo () {
    userInfo.value = {}
  }
  return {
    userInfo,
    setUserInfo,
    clearUserInfo
  }
})
